package com.woniu.gf.pawn.controller;


import com.woniu.gf.pawn.comm.core.dto.ResultDto;
import com.woniu.gf.pawn.comm.core.util.OssUntil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2020-10-13
 */
@Api(tags = "图片的控制类")
@RestController
@RequestMapping("/image")
public class ImageController {
    /**
     * 上传图片
     * @param files
     * @return
     */
    @ApiOperation("图片上传")
    @PostMapping("onload")
    public ResultDto onload(List<MultipartFile> files)  {
        List<String> url = OssUntil.putObject(files);
        return  ResultDto.success(200,"上传大类图片",url);
    }

    /**
     * 删除图片
     * @param imageAddr
     * @return
     */
    @ApiOperation("图片删除")
    @PostMapping("deleteImage")
    public  ResultDto  deleteImage( String  imageAddr)  {
        OssUntil.deleteObject(imageAddr);
        return  ResultDto.success(200,"删除大类图片");
    }

}

